from django.shortcuts import render,redirect
from rest_framework.response import Response

from news import models,ser
from rest_framework.views import APIView
# Create your views here.

class Newslist(APIView):
    def get(self,request):
        news = models.News.objects.all()
        news_ser = ser.NewsSerializer(news,many=True)
        return Response (news_ser.data)

class NewsDetail(APIView):
    def get(self,request,pk):
        news = models.News.objects.get(id=pk)
        news_ser = ser.NewsSerializer(news)
        return Response(news_ser.data)

